feat(streams): split data loading from table rendering - #1590
Merged
Jagadeeshftw merged 1 commit intoAug 31, 2026
Merged
Conversation
) Extract useStreamsData hook and StreamsListPanel component from the 1 459-line Streams.tsx monolith, then add focused regression tests for both layers. Data layer (useStreamsData.ts) - Owns useTreasury fetch, optimistic overlay, stale-request abort - Status/search/sort filter state and visibleStreams derivation - Pagination state with automatic page-clamp - Summary metrics: activeStreams, monthlyOutflow, withdrawableNow, nextUnlock - Zero-accrual banner flags - Session recovery read/write/restore/discard - Live ARIA announcement debounce - Rollback toast edge-case tracking Presentation layer (StreamsListPanel.tsx) - Pure props-in component: search input, status pills, sort select, VirtualList of StreamCards via render prop, Pagination bar, SessionPersistenceIndicator - No internal async state or side effects Tests added (80 total, all pass) - src/pages/useStreamsData.test.ts (41 tests) filters, pagination, summary metrics, zero-accrual flags, loading/error pass-through, isAbortError guard, display flags - src/components/Streams/StreamsListPanel.test.tsx (25 tests) rendering, status filter aria-pressed, search/sort callbacks, pagination wiring, session indicator props, accessibility roles - src/pages/Streams.test.tsx (14 tests, fixed) Removed broken source-code concatenation and undefined symbol refs; kept sortStreams pure-function suite and integration sort tests; added missing mocks for useOptimisticStreams and useWallet Coverage: useStreamsData.ts and StreamsListPanel.tsx added to vitest.config.ts include list. Closes Fluxora-Org#1410
|
@retkatmun Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
kindly review and merege @Jagadeeshftw |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1410
src/pages/Streams.tsxwas 1,459 lines combining network loading, filter state, pagination, session recovery, ARIA announcements, and layout in one place. This PR extracts the two layers that were already partially in place but never committed or tested.Before / After
Streams.tsxuseStreamsData.tsStreamsListPanel.tsxStreams.test.tsxuseStreamsData.tssource concatenated into it, referenced undefined symbols (RecipientStreams,writeStreamsSession,activeStream,DEFAULT_STREAMS_FILTERS)After: both layers are committed, documented, and covered by 80 focused tests.
Data layer —
useStreamsData.tsSingle hook that owns everything that touches the network or localStorage:
useTreasuryfetch +useOptimisticStreamsoverlayrefetchStreams)visibleStreamsactiveStreams,monthlyOutflow,withdrawableNow,nextUnlockshowZeroAccrual,zeroAccrualReason)useLiveAnnouncerStreams.tsxconsumes the hook through a singleconst data = useStreamsData()destructure and passes everything down to the presentation layer as props.Presentation layer —
StreamsListPanel.tsxPure props-in component with no internal state or side effects:
aria-pressed, sort selectVirtualListof stream cards via arenderStreamrender prop (panel stays agnostic toStreamCardinternals)Paginationbar wired toonPageChange/onItemsPerPageChangeSessionPersistenceIndicatorthreaded throughrecentlySavedTests — 80 total, all pass
src/pages/useStreamsData.test.ts— 41 tests (new)All via
renderHook(), zero JSX. Covers:src/components/Streams/StreamsListPanel.test.tsx— 25 tests (new)Pure render tests — no hook required:
src/pages/Streams.test.tsx— 14 tests (fixed)Removed the accidental source-code concatenation and all undefined-symbol references. Added missing mocks (
useOptimisticStreams,useWallet,lib/stellar/tx). Kept the fullsortStreamspure-function suite and integration sort tests. Added a not-found-state integration test.vitest.config.tsuseStreamsData.tsandStreamsListPanel.tsxadded to the coverageincludelist.What is unchanged
Streams.tsxpublic API and route behaviour are identical — same query params, loading states, error states, empty states, accessibility attributes, session recovery banner, zero-accrual banner, StreamCard expand/collapse, VirtualList, and Pagination.CI / verification
Pre-existing full-suite worker-timeout failures (
i18n/__tests__,Recipient.notification) are confirmed in the baselinevitest-full-run.logand are unrelated to this PR.